package com.mysqldemo.controller;

import com.mysqldemo.entity.vo.ResponseVO;
import com.mysqldemo.entity.vo.PaginationResultVO;
import com.mysqldemo.entity.po.Test;
import com.mysqldemo.entity.query.TestQuery;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import com.mysqldemo.service.TestService;
import java.util.List;
/**
 * @Description Controller
 * @Author 徐大勇
 * @Version 1.8.0_131
 * @date 2023/07/06
 */

@RestController
@RequestMapping("/test")
public class TestController  extends ABaseController{
	@Resource
	private TestService testService;
	//新增
	@RequestMapping("add")
	public ResponseVO add( Test test){
		testService.add(test);
		return getSuccessResponseVO(null);
	}
	//根据条件分页查询
	@RequestMapping("loadDateList")
	public ResponseVO loadDateList( TestQuery  query){
		return getSuccessResponseVO(testService.findListByPage(query));
	}
	//批量新增
	@RequestMapping("addBatch")
	public ResponseVO addBatch(@RequestBody List<Test> listBatch){
		testService.addBatch(listBatch);
		return getSuccessResponseVO(null);
	}
	//批量新增/更新
	@RequestMapping("addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<Test> listBatch){
		testService.addOrUpdateBatch(listBatch);
		return getSuccessResponseVO(null);
	}

	//通过Id查询
	@RequestMapping("getId")
	public ResponseVO getId(  Integer id) {
		return getSuccessResponseVO(testService.getById(id));
	}

	//通过Id修改
	@RequestMapping("updateId")
	public ResponseVO updateId( Test bean , Integer id) {
		testService.updateById(bean,id);
		return getSuccessResponseVO(null);
	}

	//通过Id删除
	@RequestMapping("deleteId")
	public ResponseVO deleteId(Integer id) {
		testService.deleteById(id);
		return getSuccessResponseVO(null);
	}

}
